package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum DetailProcess implements IBaseEnum<Serializable> {

    WMS_INSERT(0, "WMS下发任务"),

    WCS_INSERT(1, "WCS单机下发任务"),

    PRE_ASSIGN(2, "WCS预分车"),

    FORMAL_ASSIGN(3, "WCS正式分车"),

    STATION_TASK(4, "输送线任务"),

    STATION_INSTRUCTION(5, "下发输送线运行指令"),

    STATION_RUN(4, "输送线运行"),

    HOIST_RUN(6,"提升机运行"),

    HOIST_UPDATE_N(7,"更新提升机起始位置无货(提升机左右)"),

    HOIST_UPDATE_Y(8,"更新提升机起始位置有货(提升机左右)"),

    CLEAR_HOIST_TASK(9, "WCS清理提升机任务完成编号"),

    LOCK_HOIST(10, "锁定提升机"),

    UNLOCK_HOIST(11, "解锁提升机(物理锁)"),

    RGV_TASK(12,"小车任务"),

    TO_WMS_START(13,"小车上报WMS任务开始"),

    RGV_TO_START(14, "前往起点中"),

    RGV_TO_END(15, "前往终点中"),

    TO_WHOLE_ROUTE(16,"发送整体路径指令"),

    SEND_RUN(17,"发送行驶指令"),

    TO_WMS_COMMIT(18,"上报WMS任务完成"),

    PALLET_UP_INST(19,"到达起点发送托盘顶升指令"),

    PALLET_DOWN_INST(20,"到达终点发送托盘下降指令"),

    AVOID_INSERT(21,"产生避让任务"),

    ASK_HOIST(22,"请求提升机"),

    RUN_TO_HOIST(23,"等待进入提升机"),

    DRIVE_AWAY_HOIST(24,"驶离提升机"),

    UNLOCK_HOIST_WCS(25, "解锁提升机(逻辑锁)"),

    ADJUST_TASK(26, "任务车辆调整"),

    HAND_INTERRUPT(27, "手动中断RGV"),

    PALLET_DOWN_EXCEPTION(28, "托盘下降异常"),

    HAND_INTERRUPT_PLC(29, "PLC中断"),

    CREATE_PATH_FAIL(30, "路径规划失败"),

    CHANGE_END(31, "改变终点位置"),

    SYSTEM_EXCEPTION(32, "系统运行异常"),

    REST_PRE_RGV(33, "重新预分车"),

    CHANGE_EXCUTE_RGV(34, "改变执行车辆"),

    TASK_EXCUTE_DIFFERENT(35, "任务执行车辆不一致"),

    WRITE_START_Y(36, "写入自卸式提升机起点有货"),

    UNLOCK_HOIST_CONNECTION(37, "解锁提升机接驳点"),

    RES_EXCUTE_ORDER_FAIL(38, "路径规划失败"),

    PRE_ASSIGN_FAIL(39,"预分车失败"),

    AUTO_TRANSFER_TASK(40,"自卸式提升机移库"),

    HOIST_TASK(51,"提升机任务"),
    ;

    @EnumValue
    private int process;
    @JsonValue
    private String description;

    DetailProcess(int process, String description) {
        this.process = process;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static DetailProcess parsePrecess(int taskType) {
        DetailProcess[] taskTypes = DetailProcess.values();
        for (DetailProcess type : taskTypes) {
            if (type.process == taskType) {
                return type;
            }
        }
        throw new IllegalArgumentException("进度参数错误:" + taskType);
    }

    public static DetailProcess getByPrecess(int taskType) {
        DetailProcess[] taskTypes = DetailProcess.values();
        for (DetailProcess type : taskTypes) {
            if (type.process == taskType) {
                return type;
            }
        }
        return null;
    }

    public static DetailProcess parsePrecess(String description) {
        DetailProcess[] taskTypes = DetailProcess.values();
        for (DetailProcess type : taskTypes) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("进度描述错误:" + description);
    }

    public int getTypeNum() {

        return process;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getValue() {
        return process;
    }

    @Override
    public Integer getVal() {
        // TODO Auto-generated method stub
        return null;
    }


}
